/*Simple C program to convert base 10 to base 2 written for CS9207 in CEG Anna University .>
Copyright (C) <2011>  <Parikshith Mechineni>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/> */

# include <iostream.h>
# include <time.h>
# include <conio.h>
int steps=0;
void base10tobase2(long int n)
     {                  
		      static long int a[33],m,i=0;
			  steps++;
		      if (n>0)
			     {
                    a[i]=n%2;
                    i++;
                    n=n/2;
                    base10tobase2(n);
                 }
              else
			    {
			      for(m=i-1;m>=0;m--)
					     {
				      	     cout<<a[m];
					     }
			    }
     }
int main()
    {
	  clock_t start,end;
	  long int n;
	  n=65536*453;
	  cout<<"\n";
	  start=clock();
	  base10tobase2(n);
	  end = clock();
	  cout<<"\n Time taken = "<<(end-start)/CLK_TCK;
	  cout<<"no of basic steps ="<<steps;
	  getch();
	  return (0);
    }


